<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php

class OnlineListForm extends CFormModel implements IMiniyunGridConfig {
    public $searchKey;     public $action;     public $baseAction;
    public $roleAction;
    
    public function rules() {
        return array (array ('searchKey,action,baseAction,roleAction', 'length', 'max' => 128 ) );
    }
    
    public function init() {
        parent::init ();
    }
    
    
    public function getFormFilters() {
        return array ();
    }
    
    
    public function getSearchKey() {
        if ($this->action == "search") {
                        $key = $this->searchKey;
            $sql = "select device.id from ";
            $sql .= Yii::app ()->params ['tablePrefix'] . "users as user";
            $sql .= ",";
            $sql .= Yii::app ()->params ['tablePrefix'] . "online_devices as device";
            $sql .= " where user_name like '%$key%' ";
            $sql .= " and user.id = user_id";
            return $sql;
        }
    }
    
    
    public function getDataProvider() {
        return new OnlineListDataProvider ( $this );
    }
    
    
    public function getParamers($arr = array()) {
                                $pageArr = array ();
        $page = Yii::app ()->request->getParam ( 'page' );
        if (isset ( $page )) {
            $pageArr ['page'] = $page;
        }
        
        return array_merge ( $pageArr, $arr );
    }
}
?>